﻿using EPiServer.Shell.ObjectEditing.EditorDescriptors;

namespace OpenWaves.EPiServer.GeoProperties
{    
    [EditorDescriptorRegistration(TargetType = typeof(GeoPoint), UIHint = PropertyGeoPoint.UiHint)]    
    class PropertyGeoPointEditorDescriptor : PropertyGeoObjectEditorDescriptor
    {
        public PropertyGeoPointEditorDescriptor(): base()
        {
            this.ClientEditingClass = "ow-epi-geoProperties.widgets.GeoPointSelector";
        }        

        public override void ModifyMetadata(global::EPiServer.Shell.ObjectEditing.ExtendedMetadata metadata, System.Collections.Generic.IEnumerable<System.Attribute> attributes)
        {
            base.ModifyMetadata(metadata, attributes);            
            metadata.EditorConfiguration.Add("geoPickerDialogUrl", this.GetEmbeddedResourceUrl(typeof(LocationPage)));                       
            // translations                            
            AddLocalizedValue(metadata, "selectLocationText", "Click to select a location");            
            AddLocalizedValue(metadata, "latitudeText", "Latitude");
            AddLocalizedValue(metadata, "longitudeText", "Longitude");
            AddLocalizedValue(metadata, "clearText", "Clear");
            AddLocalizedValue(metadata, "zoomText", "Zoom");
        }

        protected override string PropertyUniqueName
        {
            get { return PropertyGeoPoint.UniqueName; }
        }
    }

    [EditorDescriptorRegistration(TargetType = typeof(GeoPoint), UIHint = PropertyGeoPoint.GeoPointViewUiHint)]
    class PropertyGeoPointViewEditorDescriptor: PropertyGeoPointEditorDescriptor
    {
        public PropertyGeoPointViewEditorDescriptor(): base()
        {
            
        }

        public override void ModifyMetadata(global::EPiServer.Shell.ObjectEditing.ExtendedMetadata metadata, System.Collections.Generic.IEnumerable<System.Attribute> attributes)
        {
            base.ModifyMetadata(metadata, attributes);
            metadata.EditorConfiguration.Add("isMapZoomVisible", true);
        }
    }

    public class GoogleMapsApiInfo
    {
        public int Width { get; private set; }

        public int Height { get; private set; }

        public int Zoom { get; private set; }

        private GoogleMapsApiInfo(int width, int height, int zoom)
        {
            this.Width = width;
            this.Height = height;
            this.Zoom = zoom;
        }

        public static GoogleMapsApiInfo Default
        {
            get { return new GoogleMapsApiInfo(200, 200, 11); }
        }
    }
}